package chapter2.No2_1_synchronized同步方法.dSynchronized方法与锁对象.demo2;

/**
 * *：
 *
 * @author liujian
 * @version 2016/11/11 0011
 */
public class TestObject {

    public synchronized void methodA() {
        try {
            System.out.println("Thread.currentThread().getName:"+Thread.currentThread().getName());
            Thread.sleep(1000);
            System.out.println("End");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public synchronized void methodB() {
        try {
            System.out.println("Thread.currentThread().getName:"+Thread.currentThread().getName());
            Thread.sleep(1000);
            System.out.println("End");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}
